<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>cpp_redis: cpp_redis::network::redis_connection Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="cpp_redis_logo.jpg"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">cpp_redis
   &#160;<span id="projectnumber">4.0.0</span>
   </div>
   <div id="projectbrief">cpp_redis is a C++11 Asynchronous Multi-Platform Lightweight Redis Client, with support for synchronous operations and pipelining.</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><b>cpp_redis</b></li><li class="navelem"><b>network</b></li><li class="navelem"><a class="el" href="classcpp__redis_1_1network_1_1redis__connection.html">redis_connection</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#pub-types">Public Types</a> &#124;
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="classcpp__redis_1_1network_1_1redis__connection-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">cpp_redis::network::redis_connection Class Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p><code>#include &lt;<a class="el" href="redis__connection_8hpp_source.html">redis_connection.hpp</a>&gt;</code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-types"></a>
Public Types</h2></td></tr>
<tr class="memitem:aba1a229a3d36a5540a80776ed0cf9a44"><td class="memItemLeft" align="right" valign="top">typedef std::function&lt; void(<a class="el" href="classcpp__redis_1_1network_1_1redis__connection.html">redis_connection</a> &amp;)&gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classcpp__redis_1_1network_1_1redis__connection.html#aba1a229a3d36a5540a80776ed0cf9a44">disconnection_handler_t</a></td></tr>
<tr class="separator:aba1a229a3d36a5540a80776ed0cf9a44"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a40f4b55a3103b7436e34211893377245"><td class="memItemLeft" align="right" valign="top">typedef std::function&lt; void(<a class="el" href="classcpp__redis_1_1network_1_1redis__connection.html">redis_connection</a> &amp;, <a class="el" href="classcpp__redis_1_1reply.html">reply</a> &amp;)&gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classcpp__redis_1_1network_1_1redis__connection.html#a40f4b55a3103b7436e34211893377245">reply_callback_t</a></td></tr>
<tr class="separator:a40f4b55a3103b7436e34211893377245"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:aee0302e4ff9c9b5b2e7f467d869d45f7"><td class="memItemLeft" align="right" valign="top"><a id="aee0302e4ff9c9b5b2e7f467d869d45f7"></a>
&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classcpp__redis_1_1network_1_1redis__connection.html#aee0302e4ff9c9b5b2e7f467d869d45f7">redis_connection</a> (void)</td></tr>
<tr class="memdesc:aee0302e4ff9c9b5b2e7f467d869d45f7"><td class="mdescLeft">&#160;</td><td class="mdescRight">ctor <br /></td></tr>
<tr class="separator:aee0302e4ff9c9b5b2e7f467d869d45f7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6880cfb2e1b037fcdaa5f0a6d515b375"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classcpp__redis_1_1network_1_1redis__connection.html#a6880cfb2e1b037fcdaa5f0a6d515b375">redis_connection</a> (const std::shared_ptr&lt; <a class="el" href="classcpp__redis_1_1network_1_1tcp__client__iface.html">tcp_client_iface</a> &gt; &amp;<a class="el" href="classcpp__redis_1_1network_1_1tcp__client.html">tcp_client</a>)</td></tr>
<tr class="separator:a6880cfb2e1b037fcdaa5f0a6d515b375"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a9d392191ce262eddd5570b57e07aa051"><td class="memItemLeft" align="right" valign="top"><a id="a9d392191ce262eddd5570b57e07aa051"></a>
&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classcpp__redis_1_1network_1_1redis__connection.html#a9d392191ce262eddd5570b57e07aa051">~redis_connection</a> (void)</td></tr>
<tr class="memdesc:a9d392191ce262eddd5570b57e07aa051"><td class="mdescLeft">&#160;</td><td class="mdescRight">dtor <br /></td></tr>
<tr class="separator:a9d392191ce262eddd5570b57e07aa051"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2bdd38bbfd5d97aeca8e433465c4d621"><td class="memItemLeft" align="right" valign="top"><a id="a2bdd38bbfd5d97aeca8e433465c4d621"></a>
&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classcpp__redis_1_1network_1_1redis__connection.html#a2bdd38bbfd5d97aeca8e433465c4d621">redis_connection</a> (const <a class="el" href="classcpp__redis_1_1network_1_1redis__connection.html">redis_connection</a> &amp;)=delete</td></tr>
<tr class="memdesc:a2bdd38bbfd5d97aeca8e433465c4d621"><td class="mdescLeft">&#160;</td><td class="mdescRight">copy ctor <br /></td></tr>
<tr class="separator:a2bdd38bbfd5d97aeca8e433465c4d621"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a54a4c28ad1b9e9f3bac2854fddf4e30d"><td class="memItemLeft" align="right" valign="top"><a id="a54a4c28ad1b9e9f3bac2854fddf4e30d"></a>
<a class="el" href="classcpp__redis_1_1network_1_1redis__connection.html">redis_connection</a> &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classcpp__redis_1_1network_1_1redis__connection.html#a54a4c28ad1b9e9f3bac2854fddf4e30d">operator=</a> (const <a class="el" href="classcpp__redis_1_1network_1_1redis__connection.html">redis_connection</a> &amp;)=delete</td></tr>
<tr class="memdesc:a54a4c28ad1b9e9f3bac2854fddf4e30d"><td class="mdescLeft">&#160;</td><td class="mdescRight">assignment operator <br /></td></tr>
<tr class="separator:a54a4c28ad1b9e9f3bac2854fddf4e30d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af105573e46eadbc34a9f5907832df19f"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classcpp__redis_1_1network_1_1redis__connection.html#af105573e46eadbc34a9f5907832df19f">connect</a> (const std::string &amp;host=&quot;127.0.0.1&quot;, std::size_t port=6379, const <a class="el" href="classcpp__redis_1_1network_1_1redis__connection.html#aba1a229a3d36a5540a80776ed0cf9a44">disconnection_handler_t</a> &amp;disconnection_handler=nullptr, const <a class="el" href="classcpp__redis_1_1network_1_1redis__connection.html#a40f4b55a3103b7436e34211893377245">reply_callback_t</a> &amp;reply_callback=nullptr, std::uint32_t timeout_msecs=0)</td></tr>
<tr class="separator:af105573e46eadbc34a9f5907832df19f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a614a01ce8abd69b44f3d072423d2e696"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classcpp__redis_1_1network_1_1redis__connection.html#a614a01ce8abd69b44f3d072423d2e696">disconnect</a> (bool wait_for_removal=false)</td></tr>
<tr class="separator:a614a01ce8abd69b44f3d072423d2e696"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad3d96826e2e67fb3fed23280237d4d9c"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classcpp__redis_1_1network_1_1redis__connection.html#ad3d96826e2e67fb3fed23280237d4d9c">is_connected</a> (void) const</td></tr>
<tr class="separator:ad3d96826e2e67fb3fed23280237d4d9c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a98c163ce431e85e46e139211564b7b3f"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classcpp__redis_1_1network_1_1redis__connection.html">redis_connection</a> &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classcpp__redis_1_1network_1_1redis__connection.html#a98c163ce431e85e46e139211564b7b3f">send</a> (const std::vector&lt; std::string &gt; &amp;redis_cmd)</td></tr>
<tr class="separator:a98c163ce431e85e46e139211564b7b3f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8e6980d40139877c16e995051b780d60"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classcpp__redis_1_1network_1_1redis__connection.html">redis_connection</a> &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classcpp__redis_1_1network_1_1redis__connection.html#a8e6980d40139877c16e995051b780d60">commit</a> (void)</td></tr>
<tr class="separator:a8e6980d40139877c16e995051b780d60"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>tcp connection wrapper handling redis protocol </p>
</div><h2 class="groupheader">Member Typedef Documentation</h2>
<a id="aba1a229a3d36a5540a80776ed0cf9a44"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aba1a229a3d36a5540a80776ed0cf9a44">&#9670;&nbsp;</a></span>disconnection_handler_t</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">typedef std::function&lt;void(<a class="el" href="classcpp__redis_1_1network_1_1redis__connection.html">redis_connection</a>&amp;)&gt; <a class="el" href="classcpp__redis_1_1network_1_1redis__connection.html#aba1a229a3d36a5540a80776ed0cf9a44">cpp_redis::network::redis_connection::disconnection_handler_t</a></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>disconnection handler takes as parameter the instance of the <a class="el" href="classcpp__redis_1_1network_1_1redis__connection.html">redis_connection</a> </p>

</div>
</div>
<a id="a40f4b55a3103b7436e34211893377245"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a40f4b55a3103b7436e34211893377245">&#9670;&nbsp;</a></span>reply_callback_t</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">typedef std::function&lt;void(<a class="el" href="classcpp__redis_1_1network_1_1redis__connection.html">redis_connection</a>&amp;, <a class="el" href="classcpp__redis_1_1reply.html">reply</a>&amp;)&gt; <a class="el" href="classcpp__redis_1_1network_1_1redis__connection.html#a40f4b55a3103b7436e34211893377245">cpp_redis::network::redis_connection::reply_callback_t</a></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>reply handler takes as parameter the instance of the <a class="el" href="classcpp__redis_1_1network_1_1redis__connection.html">redis_connection</a> and the built reply </p>

</div>
</div>
<h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a id="a6880cfb2e1b037fcdaa5f0a6d515b375"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a6880cfb2e1b037fcdaa5f0a6d515b375">&#9670;&nbsp;</a></span>redis_connection()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">cpp_redis::network::redis_connection::redis_connection </td>
          <td>(</td>
          <td class="paramtype">const std::shared_ptr&lt; <a class="el" href="classcpp__redis_1_1network_1_1tcp__client__iface.html">tcp_client_iface</a> &gt; &amp;&#160;</td>
          <td class="paramname"><em>tcp_client</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">explicit</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>ctor allowing to specify custom tcp client (default ctor uses the default tacopie tcp client)</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname"><a class="el" href="classcpp__redis_1_1network_1_1tcp__client.html">tcp_client</a></td><td>tcp client to be used for network communications </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="a8e6980d40139877c16e995051b780d60"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a8e6980d40139877c16e995051b780d60">&#9670;&nbsp;</a></span>commit()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classcpp__redis_1_1network_1_1redis__connection.html">redis_connection</a>&amp; cpp_redis::network::redis_connection::commit </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>commit pipelined transaction that is, send to the network all commands pipelined by calling <a class="el" href="classcpp__redis_1_1network_1_1redis__connection.html#a98c163ce431e85e46e139211564b7b3f">send()</a></p>
<dl class="section return"><dt>Returns</dt><dd>current instance </dd></dl>

</div>
</div>
<a id="af105573e46eadbc34a9f5907832df19f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af105573e46eadbc34a9f5907832df19f">&#9670;&nbsp;</a></span>connect()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void cpp_redis::network::redis_connection::connect </td>
          <td>(</td>
          <td class="paramtype">const std::string &amp;&#160;</td>
          <td class="paramname"><em>host</em> = <code>&quot;127.0.0.1&quot;</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">std::size_t&#160;</td>
          <td class="paramname"><em>port</em> = <code>6379</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="classcpp__redis_1_1network_1_1redis__connection.html#aba1a229a3d36a5540a80776ed0cf9a44">disconnection_handler_t</a> &amp;&#160;</td>
          <td class="paramname"><em>disconnection_handler</em> = <code>nullptr</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="classcpp__redis_1_1network_1_1redis__connection.html#a40f4b55a3103b7436e34211893377245">reply_callback_t</a> &amp;&#160;</td>
          <td class="paramname"><em>reply_callback</em> = <code>nullptr</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">std::uint32_t&#160;</td>
          <td class="paramname"><em>timeout_msecs</em> = <code>0</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>connect to the given host and port, and set both disconnection and reply callbacks</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">host</td><td>host to be connected to </td></tr>
    <tr><td class="paramname">port</td><td>port to be connected to </td></tr>
    <tr><td class="paramname">disconnection_handler</td><td>handler to be called in case of disconnection </td></tr>
    <tr><td class="paramname">reply_callback</td><td>handler to be called once a reply is ready </td></tr>
    <tr><td class="paramname">timeout_msecs</td><td>max time to connect (in ms) </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a614a01ce8abd69b44f3d072423d2e696"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a614a01ce8abd69b44f3d072423d2e696">&#9670;&nbsp;</a></span>disconnect()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void cpp_redis::network::redis_connection::disconnect </td>
          <td>(</td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>wait_for_removal</em> = <code>false</code></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>disconnect from redis server</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">wait_for_removal</td><td>when sets to true, disconnect blocks until the underlying TCP client has been effectively removed from the io_service and that all the underlying callbacks have completed. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="ad3d96826e2e67fb3fed23280237d4d9c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad3d96826e2e67fb3fed23280237d4d9c">&#9670;&nbsp;</a></span>is_connected()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool cpp_redis::network::redis_connection::is_connected </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
</div><div class="memdoc">
<dl class="section return"><dt>Returns</dt><dd>whether we are connected to the redis server or not </dd></dl>

</div>
</div>
<a id="a98c163ce431e85e46e139211564b7b3f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a98c163ce431e85e46e139211564b7b3f">&#9670;&nbsp;</a></span>send()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classcpp__redis_1_1network_1_1redis__connection.html">redis_connection</a>&amp; cpp_redis::network::redis_connection::send </td>
          <td>(</td>
          <td class="paramtype">const std::vector&lt; std::string &gt; &amp;&#160;</td>
          <td class="paramname"><em>redis_cmd</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>send the given command the command is actually pipelined and only buffered, so nothing is sent to the network please call <a class="el" href="classcpp__redis_1_1network_1_1redis__connection.html#a8e6980d40139877c16e995051b780d60">commit()</a> to flush the buffer</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">redis_cmd</td><td>command to be sent </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>current instance </dd></dl>

</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li>includes/cpp_redis/network/<a class="el" href="redis__connection_8hpp_source.html">redis_connection.hpp</a></li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.13
</small></address>
</body>
</html>
